package com.springboot.study.tests.designpattern.flyweight;

import java.awt.*;

/**
 * @Author: guodong
 * @Date: 2021/5/8 14:41
 * @Version: 1.0
 * @Description:
 */
public class FlyweightClient {

    public void playChess() {
        //下黑子
        Chess backChess1 = ChessFactory.getChess(Color.BLACK);
        backChess1.draw(2, 5);

        //下白子
        Chess whiteChess = ChessFactory.getChess(Color.WHITE);
        whiteChess.draw(3, 5);

        //下黑子
        Chess backChess2 = ChessFactory.getChess(Color.BLACK);
        backChess2.draw(2, 6);

        System.out.println(String.format("backChess1:%d | backChess2:%d | whiteChess:%d",
                backChess1.hashCode(), backChess2.hashCode(), whiteChess.hashCode()));
    }

    public static void main(String[] args) {
        new FlyweightClient().playChess();
    }

}
